from django.db import models

# Create your models here.



class UserModel(models.Model):
    username = models.CharField(max_length=20,verbose_name='用户名')
    phone = models.CharField(max_length=11,unique=True,verbose_name='手机号')
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='创建时间')

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = '用户表'
        verbose_name_plural = verbose_name


class SFUserModel(models.Model):
    TYPE_CHOICES = (
        (0, '钉钉登录'),
        (1, '微博登录'),
    )
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE,db_constraint=False, verbose_name='用户')
    type = models.SmallIntegerField(default=0, choices=TYPE_CHOICES, verbose_name='类型')
    uid = models.CharField(max_length=200, verbose_name='第三方用户ID')

    def __str__(self):
        return self.user.username

    class Meta:
        verbose_name = '第三方用户表'
        verbose_name_plural = verbose_name


class IdentityModel(models.Model):
    SEX_CHOICES = (
        (0, '男'),
        (1, '女'),
    )

    user = models.OneToOneField(UserModel, on_delete=models.CASCADE, db_constraint=False, verbose_name='用户'
                                ,related_name="identity_user")
    username = models.CharField(max_length=50, verbose_name='姓名')
    sex = models.SmallIntegerField(verbose_name='性别')
    race = models.CharField(max_length=20, verbose_name='民族')
    birthday = models.DateField(null=True, blank=True, verbose_name='出生日期')
    id_card = models.CharField(max_length=200, verbose_name='身份证号')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = '身份信息表'
        verbose_name_plural = verbose_name




